﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Sockets;

namespace Sofire.DataComm.Net
{
    /// <summary>
    /// 表示可靠套接字接收数据后发生的事件委托。
    /// </summary>
    /// <param name="sender">事件对象。</param>
    /// <param name="e">事件参数。</param>
    public delegate void ReceivingEventHandler(object sender, ReceivedEventArgs e);

    /// <summary>
    /// 表示可靠套接字接收数据后发生的事件参数。
    /// </summary>
    public class ReceivingEventArgs : ReceivedEventArgs
    {
        private bool _KeepBuffer = true;
        /// <summary>
        /// 设置或获取一个值，表示是否保留缓冲区数据。默认为 true，表示不清空缓冲数据。
        /// </summary>
        public bool KeepBuffer
        {
            get
            {
                return this._KeepBuffer;
            }
            set
            {
                this._KeepBuffer = value;
            }
        }

        /// <summary>
        /// 初始化 <see cref="Sofire.DataComm.Net.ReceivingEventArgs"/> 的新实例。
        /// </summary>
        /// <param name="fromSocket">发送字节数据的 <see cref="System.Net.Sockets.Socket"/>。</param>
        /// <param name="data">接收的所有字节数据。</param>
        public ReceivingEventArgs(Socket fromSocket, byte[] data) : base(fromSocket, data) { }
    }
}
